Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

London 9 - Lovelace - Oleksii Chepurnyi - JavaScript-Core1-Coursework-Week1 - #435

Open
OleksChep wants to merge 23 commits into
CodeYourFuture:masterfrom
OleksChep:master
Open

London 9 - Lovelace - Oleksii Chepurnyi - JavaScript-Core1-Coursework-Week1#435
OleksChep wants to merge 23 commits into
CodeYourFuture:masterfrom
OleksChep:master

Conversation

@OleksChep

@OleksChep OleksChep commented Nov 24, 2022

Copy link
Copy Markdown

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name: Oleksii Chepurnyi
  • Your City: London
  • Your Slack Name: Oleks

Homework Details

  • Module: JavaScript-Core1-Coursework-Week1
  • Week: 1

Notes

  • What did you find easy?
    Operators
  • What did you find hard?
    Functions / TESTS !
  • What do you still not understand?
    Tests / How it works ?
  • Any other notes?
    How works Tests ?

View rendered exercises/K-functions-parameters/README.md

@maxf
maxf self-requested a review November 24, 2022 13:54

@jonnywyatt jonnywyatt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You smashed this! Well done.

var introduce2 = "characters long.";
var message =
introduce1 + name1 + " " + introduce3 + nameLength + " " + introduce2;
console.log(message.trim()); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

var ment = "Number of mentors: ";
console.log(ment + numberOfMentors);
var total = "Total number of students and mentors: ";
var sum = numberOfMentors + numberOfStudents;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

// Complete the function so that it takes input parameters
function multiply() {
// Calculate the result of the function and return it
function multiply(a, b) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect

Comment thread extra/1-currency-conversion.js Outdated
function convertToUSD() {}
function convertToUSD(price) {
let priceDolar = pricePound*1.4;
return "$" + priceDolar.toFixed(2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent - toFixed is the right thing to use here

Comment thread mandatory/1-syntax-errors.js Outdated
return a + b + c;
}
function introduceMe(name, age) {
return "Hello, my name is " + '${name}' + "and I am " + '${age}' + " years old";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will '${name}' just print out the name?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don t know

Comment thread mandatory/1-syntax-errors.js Outdated

return "The total is total";
total = a + b;
return "The total is ${total}";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close - you're using template string syntax here, but to make it work you need to use backticks ` instead of " to surround the string.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't use backticks then ${total} won't be replaced by the value of total. For instance:

let a = 34;
console.log("a is ${a}");   // will print: a is ${a}
console.log(`a is ${a}`);   // will print: a is 34

//The implementation selects the initial seed to the random number generation
//algorithm; it cannot be chosen or reset by the user.
//Return value A floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive).
// 0 < Number < 10 ;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated number will be between 0 and 1
so, 0 < Number < 1

Comment thread mandatory/4-tax.js
function addTaxAndFormatCurrency() {}
function addTaxAndFormatCurrency(price) {
let newPrice = calculateSalesTax(price);
return "£" + newPrice.toFixed(2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Maybe one small improvement? Every time you use the calculateSalesTax function, you'll have to call toFixed on the result. How can you save from having to do that each time you call it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not understand question , sorry

@maxf maxf left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, you've got it mostly right.
Did you run the tests, as explained in the README file?
Not all of them pass, so I just want to check if you managed to run them yourself?

Also, when you answer the questions (what did you find easy, etc), you're allowed to use more than one word!

And thanks a lot @jonnywyatt for your review :)

@@ -1,3 +1,7 @@
// Start by creating a variable `greeting`

var greeting = "Hello world";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should avoid var. As mentioned last week, prefer using let or const. var is old, has tricky semantics, and is no longer needed.


var name1 = "Oleks";
var nameLength = name1.length;
var introduce1 = " My name is ";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all the whitespace at the start?

var total = "Total number of students and mentors: ";
var sum = numberOfMentors + numberOfStudents;
console.log(total + sum);
var percentageStudents = 100*numberOfStudents/sum

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don' forget the ; at the end of the line. Even if it won't change the behaviour of your code, it's better to stay consistent.

// Declare your function first

function divide ( a, b) {
return a / b;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation of this line is 4 characters, while you use 1 above in your code. Again, for the sake of consistency and readability, always use the same amount.

*/

function convertToUSD() {}
function convertToUSD(price) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant pricePound here.
Otherwise it's good idea to use the currency in the name of the variable or parameter. Same with units: distanceInMeters, waveLengthCm, etc. It can be useful to avoid any confusion when sharing your code.

Comment thread mandatory/2-logic-error.js Outdated

function getStringLength(word) {
return "word".length();
return word.length();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's word.length. It's unclear why JavaScript does it this way, so we just accept it :)

@OleksChep

Copy link
Copy Markdown
Author

Thanks for the review

@OleksChep

Copy link
Copy Markdown
Author

Well done, you've got it mostly right. Did you run the tests, as explained in the README file? Not all of them pass, so I just want to check if you managed to run them yourself?
I did not run the tests

Also, when you answer the questions (what did you find easy, etc), you're allowed to use more than one word!

And thanks a lot @jonnywyatt for your review :)

@OleksChep

Copy link
Copy Markdown
Author

How
pass tests ?

@maxf

maxf commented Nov 28, 2022

Copy link
Copy Markdown

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants